
package com.saturday.uid.config;

import com.saturday.uid.buffer.RingBuffer;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(
        prefix = "saturday.uid.ring.buffer"
)
@Data
public class UidRingBufferProperties {

    /**
     * RingBuffer size扩容参数, 可提高UID生成的吞吐量，默认3
     */
    private int boostPower = 3;

    /**
     * 指定何时向RingBuffer中填充UID, 取值为百分比(0, 100), 默认为50
     * 举例:
     *  bufferSize=1024, paddingFactor=50 -> threshold=1024 * 50 / 100 = 512.
     *  当环上可用UID数量 < 512时, 将自动对RingBuffer进行填充补全
     */
    private int paddingFactor = RingBuffer.DEFAULT_PADDING_PERCENT;

    /**
     * 默认:不配置此项, 即不实用Schedule线程. 如需使用, 请指定Schedule线程时间间隔, 单位:秒
     * 注:另外一种RingBuffer填充时机, 在Schedule线程中, 周期性检查填充
     */
    private Long scheduleInterval;

    public int getBoostPower() {
        return boostPower;
    }

    public void setBoostPower(int boostPower) {
        this.boostPower = boostPower;
    }

    public int getPaddingFactor() {
        return paddingFactor;
    }

    public void setPaddingFactor(int paddingFactor) {
        this.paddingFactor = paddingFactor;
    }

    public Long getScheduleInterval() {
        return scheduleInterval;
    }

    public void setScheduleInterval(Long scheduleInterval) {
        this.scheduleInterval = scheduleInterval;
    }
}
